<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <button @click="num++">{{num}}</button>
        <button @click="num += 5">{{num}}</button>
        <button @click="summation">{{num}}</button>
        <button @click="summation1(3)">{{num}}</button>
        <!-- 对象语法 (2.4.0+) -->
        <button v-on="{ mousedown: doThis, mouseout: doThat }">对象</button>
        <!-- 
            以下代码不可以!!!
            因为插值语法中是直接访问vm身上的属性和方法
        -->
        <button @click="alert(111)">alert</button>
    </div>
    <script>
        Vue.config.productionTip = false;
        
        const vm = new Vue({
            el: "#app",
            data() {
                return {
                    num: 0
                }
            },
            methods: {
                summation() {
                    this.num++;
                },
                summation1(n) {
                    this.num += n;
                },
                doThis() {
                    alert(111);
                },
                doThat() {
                    alert(222)
                }
            },
        })
</script>
</body>

</html>